package br.usp.icmc.biomac.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;

/**
 * @author dilvan
 *In order to be accessible via a URL, an Activity needs a corresponding Place.
 *A Place extends com.google.gwt.app.place.Place and must have an associated PlaceTokenizer which
 *knows how to serialize the Place's state to a URL token. By default, the URL consists of the 
 *Place's simple class name (like "HelloPlace") followed by a colon (:) and the token returned by the PlaceTokenizer.
 */
public class ImagePlace extends Place {
    
	private final String token;

    public ImagePlace(String token) {
        this.token = token;
    }

    public String getToken() {
        return token;
    }
    
    /**
     * ImageListViewImpl uses a URL to go to ImagePlace. This constant
     * is used in ImageListViewImpl to make explicit the dependence
     * between the two classes (avoiding a magic string in ImageListViewImpl
     * with the name of this class);
     */
    public static final String URL = "ImagePlace";

    public static class Tokenizer implements PlaceTokenizer<ImagePlace> {
        @Override
        public String getToken(ImagePlace place) {
            return place.getToken();
        }

        @Override
        public ImagePlace getPlace(String token) {
            return new ImagePlace(token);
        }
    }
}